-
-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gtk: Implementable implementation for AccessibleText #1789
base: master
Are you sure you want to change the base?
Conversation
let mut c_ranges = glib::Slice::with_capacity(attrs.len()); | ||
let mut c_names = glib::StrV::with_capacity(attrs.len()); | ||
let mut c_values = glib::StrV::with_capacity(attrs.len()); | ||
|
||
for (range, name, value) in attrs { | ||
c_ranges.push(range); | ||
c_names.push(name); | ||
c_values.push(value); | ||
} | ||
|
||
*ranges = c_ranges.to_glib_container().0; | ||
*attribute_names = c_names.into_glib_ptr(); | ||
*attribute_values = c_values.into_glib_ptr(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like having to juggle the collections like that here, and in get_default_attributes
, but having to return three Vec from this function would also be odd. Semantically these are triples, but they are supposed to be stored in three different arrays.
A wrapper type could solve the problem but I'm not sure we should introduce two of these just for this one-off.
dadc102
to
d3daa8a
Compare
I am a little unsure if it's ever ok to return null in get_contents(_at) or not. Should I return an empty gbytes instead? |
I don't have the time to review this right now but two questions:
|
We can postpone it for now.
Sure, that makes sense. It's quite an involved interface. |
#[doc(alias = "GtkAccessibleTextRange")] | ||
#[repr(transparent)] | ||
pub struct AccessibleTextRange(crate::ffi::GtkAccessibleTextRange); | ||
use glib::translate::UnsafeFrom; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use glib::translate::UnsafeFrom; | |
use glib::translate::*; |
#[repr(transparent)] | ||
pub struct AccessibleTextRange(crate::ffi::GtkAccessibleTextRange); | ||
use glib::translate::UnsafeFrom; | ||
use gtk4_sys::GtkAccessibleTextRange; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You import it, then only use it in certain places... Usually we do use crate::ffi;
and call ffi types with ffi::$Type
or functions as well.
glib::wrapper! { | ||
#[doc(alias = "GtkAccessibleTextRange")] | ||
pub struct AccessibleTextRange(BoxedInline<crate::ffi::GtkAccessibleTextRange>); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be moved to a separate commit.
use crate::accessible_text_range::AccessibleTextRange; | ||
use crate::subclass::prelude::*; | ||
use crate::{ffi, AccessibleText, AccessibleTextGranularity}; | ||
use glib::object::Cast; | ||
use glib::translate::*; | ||
use glib::GString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use crate::accessible_text_range::AccessibleTextRange; | |
use crate::subclass::prelude::*; | |
use crate::{ffi, AccessibleText, AccessibleTextGranularity}; | |
use glib::object::Cast; | |
use glib::translate::*; | |
use glib::GString; | |
use crate::{ffi,subclass::prelude::*, AccessibleText,AccessibleTextRange, prelude::*, AccessibleTextGranularity}; | |
use glib::{translate::*, GString}; |
|
||
let func = (*parent_iface) | ||
.get_contents | ||
.expect("no parent \"get_contents\" implementation"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required? Usually we return None if there is no override/default implementation
No description provided.